package com.fs.chatx.module.common.config;
import com.fs.chatx.module.common.service.MinioService;
import io.minio.MinioClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@ConfigurationProperties(prefix = "minio") // 绑定配置前缀
public class MinioConfig
{

    private String endpoint; // 仅需主机名或 IP（如 "localhost"）
    private String accessKey;
    private String secretKey;
    private String bucketName;


    @Bean
    public MinioClient minioClient()
    {
        return MinioClient.builder()
                .endpoint(endpoint)
                .credentials(accessKey, secretKey)
                .build();
    }

    @Bean
    public MinioService minioService(MinioClient client)
    {
        return new MinioService(minioClient());
    }
}
